package com.newcoder.community.utill;




import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;


public class CookieUtill {
    public static String getValue(HttpServletRequest req, String cookieName){
        if(req==null||cookieName==null){
          throw new IllegalArgumentException("参数为空");
        }
        Cookie[] cookies = req.getCookies();
        if(cookies!=null){
            for (Cookie cookie : cookies) {
                if(cookie.getName().equals(cookieName)){
                    return cookie.getValue();
                }
            }
        }

        return null;
    }
}
